package com.bbz.core.bloomfilter;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

public class GuavaBloomFilter {
    public static void main(String args[]) {
        long star = System.currentTimeMillis();
        BloomFilter<Integer> filter = BloomFilter.create(
                Funnels.integerFunnel(),
                10000000,
                0.01);
        for (int i = 0; i < 10000000; i++) {
            filter.put(i);
        }
        //判断是否有元素1
        System.out.println(filter.mightContain(1));
        //判断是否有元素2
        System.out.println(filter.mightContain(2));
        //判断是否有元素3
        System.out.println(filter.mightContain(3));
        //判断是否有元素10000000
        System.out.println(filter.mightContain(10000000));
        long end = System.currentTimeMillis();
        System.out.println("执行时间：" + (end - star));
    }
}
